#include "eveCommon.h"
#include "eveD3DVertexBuffer.h"
#include "eveD3D9RenderSystem.h"

D3DVertexBuffer::D3DVertexBuffer(uint8 vertexsize,uint32 vertexNum,DWORD fvf,DWORD primType,DWORD usage)
: m_pVB(NULL)
, m_VertexSize(vertexsize)
, m_VertexNum(vertexNum)
, m_FVF(fvf)
, m_primType(primType)
{
	m_pVB = RenderSystem::GetSingleton()->CreateVertexBuffer(vertexsize*vertexNum,usage,fvf,D3DPOOL_DEFAULT);
}

D3DVertexBuffer::~D3DVertexBuffer()
{
	SAFE_RELEASE(m_pVB);
}

BYTE* D3DVertexBuffer::Lock(uint32 offset,uint32 size,DWORD flags)
{
	BYTE* pdata = NULL;
	m_pVB->Lock(offset,size,(void**)(&pdata),flags);
	return pdata;
}

void D3DVertexBuffer::unLock()
{
	m_pVB->Unlock();
}